package com.ttbj.util;

import java.util.List;

import com.ttbj.constant.FlagEnum;
import com.ttbj.product.bean.dto.DriverDto;
import com.ttbj.product.bean.dto.ViewData;

public class ViewModelUtil {
	private static ViewData viewData = null;

	public static ViewData buildSuccess(String message) {
		viewData = new ViewData();
		viewData.setMessage(message);
		viewData.setStatus(FlagEnum.SUCCESS.code());
		return viewData;
	}

	public static ViewData buildSuccess(String message, Object data) {
		viewData = new ViewData();
		viewData.setMessage(message);
		viewData.setStatus(FlagEnum.SUCCESS.code());
		viewData.setData(data);
		return viewData;
	}

	public static ViewData buildSuccessPage(String message, List<?> data, Integer total) {
		viewData = new ViewData();
		viewData.setMessage(message);
		viewData.setStatus(FlagEnum.SUCCESS.code());
		viewData.setRows(data);
		viewData.setTotal(total);
		return viewData;
	}

	public static ViewData buildSuccess(int code, String message, Object data) {
		viewData = new ViewData();
		viewData.setStatus(code);
		viewData.setMessage(message);
		viewData.setData(data);
		return viewData;
	}

	public static ViewData buildFailure(int code, String message) {
		viewData = new ViewData();
		viewData.setStatus(code);
		viewData.setMessage(message);
		return viewData;
	}

	public static ViewData buildFailure(int code, String message, Object data) {
		viewData = new ViewData();
		viewData.setStatus(code);
		viewData.setMessage(message);
		viewData.setData(data);
		return viewData;
	}

}
